import { OmitType } from "@nestjs/swagger";
import { IsArray, IsOptional, IsString } from "class-validator";
import { PaginationDto } from "src/common/dto/pagination.dto";
import { Role } from "../entities/role.entity";
import { Type } from "class-transformer";

/**
 * 分页查询
 */
export class ReqSearchRoleDto extends PaginationDto {
  @IsOptional()
  @IsString()
  role_name?: string;
}

export class ReqAddRoleDto extends OmitType(Role, ["role_id"] as const) {
  // 菜单id数组
  @IsArray()
  menu_ids: number[];
}

/* 编辑角色 */
export class ReqUpdateRoleDto extends Role {
  @Type()
  role_id: number;

  @IsArray()
  menu_ids: number[];
}
